package website.digitalocean.chapter8;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: longhc@citycloud.com.cn
 * @since: 2023/2/10 14:03
 * @version: 1.0
 */
@Slf4j
public class ShapeFactory {
    private static final Map<String, Shape> SHAPE_MAP = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle shape = (Circle) SHAPE_MAP.get(color);
        if (shape == null) {
            shape = new Circle(color);
            SHAPE_MAP.put(color, shape);
            log.info("创建新图形; color:{}", color);
        }
        return shape;
    }
}
